<div class="layui-fluid layui-anim febs-anim" id="detail-cost" lay-title="明细费用">
    <div class="febs-container layui-card">
        <div class="layui-card-body">
            <div id="query-project-form">
                <form class="layui-form layui-table-form" lay-filter="query-detail-table-form" id="query-detail-table-form">
                    <div class="layui-row">
                        <div class="layui-col-md3 layui-col-sm3 layui-col-xs3">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label layui-form-label-sm">公司名称</label>
                                    <div class="layui-input-inline">
                                        <div id="company-select"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3 layui-col-sm3 layui-col-xs3">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label layui-form-label-sm">项目名称</label>
                                    <div class="layui-input-inline">
                                        <div id="project-select"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3 layui-col-sm3 layui-col-xs3">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label layui-form-label-sm">年份</label>
                                    <div class="layui-input-inline">
                                        <input type="text" class="layui-input" name="year" id="date-select">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3 layui-col-sm3 layui-col-xs3">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label layui-form-label-sm">月份</label>
                                    <div class="layui-input-inline">
                                        <select name="month" lay-verify="select-month">
                                            <option value="01">一月</option>
                                            <option value="02">二月</option>
                                            <option value="03">三月</option>
                                            <option value="04">四月</option>
                                            <option value="05">五月</option>
                                            <option value="06">六月</option>
                                            <option value="07">七月</option>
                                            <option value="08">八月</option>
                                            <option value="09">九月</option>
                                            <option value="10">十月</option>
                                            <option value="11">十一月</option>
                                            <option value="12">十二月</option>
                                            <option value="balance">差额</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md3 layui-col-sm3 layui-col-xs3">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label layui-form-label-sm">查询</label>
                                    <div class="layui-input-inline">
                                        <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="query-detail">
                                            <i class="layui-icon">&#xe848;</i>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
                <hr class="layui-border-green">
            </div>
            <div id="projectInfo">
                <div class="layui-collapse">
                    <div class="layui-colla-item">
                        <h2 class="layui-colla-title">公司信息</h2>
                        <div class="layui-colla-content layui-show">
                           <ul>
                               <li style="margin-bottom: 10px">公司名称: <strong id="company_name_display"></strong></li>
                               <li style="margin-bottom: 10px">项目名称: <strong id="project_name_display"></strong></li>
                               <li style="margin-bottom: 10px">项目核算年月: <strong id="year_month_display"></strong></li>
                               <li style="margin-bottom: 10px">查看批注:
                                   <button class="layui-btn  layui-btn-sm" id="detail-comment">批注(含第三方)</button>
                                   <button class="layui-btn  layui-btn-sm" id="detail-comment2" shiro:hasPermission="test">批注(含管理成本及补助减免)</button>
                               </li>
                           </ul>
                        </div>
                    </div>
                </div>
            </div>
            <div>
                <div class="layui-collapse" id="project-detail-info">

                </div>
                <hr class="layui-border-green">
                <div style="text-align:center">
                    <button class="layui-btn" id="detail-submit">保存</button>
                </div>
            </div>

        </div>
    </div>
</div>
<script data-th-inline="none" type="text/javascript">
    let mainSubjectListData,
        detailSubjectListData,
        selfIncomeIndex = 6,
        incomeExtraIndex = 7,
        taxCodes = ['bdd950854a0311ecba500242ac110002', 'c22f36054a0311ecba500242ac110002', 'c6f9e5074a0311ecba500242ac110002'],
        manualTax = 0,
        costDetailData = {};

    layui.use(['laydate', 'jquery', 'laydate', 'febs', 'form', 'eleTree', 'table', 'validate', 'xmSelect', 'layer'], function () {
        let $ = layui.jquery,
            laydate = layui.laydate,
            febs = layui.febs,
            form = layui.form,
            xmSelect = layui.xmSelect,
            companyXmSelect,
            $view = $('#detail-cost'),
            $submit = $view.find('#detail-submit'),
            $detailComment = $view.find('#detail-comment'),
            $detailComment2 = $view.find('#detail-comment2'),
            $query_detail = $view.find('#query-detail'),
            $queryDetailTableForm = $view.find('#query-detail-table-form'),
            $companyNameDisplay = $view.find('#company_name_display'),
            $projectNameDisplay = $view.find('#project_name_display'),
            $yearMonthDisplay = $view.find('#year_month_display'),
            $projectDetailInfo = $view.find('#project-detail-info'),
            projectInfo = {},
            $layer = layui.layer,
            treeNum = 1,
            selfIndex = [],
            thirdIndex = [],
            selfTreeData = [],
            thirdTreeData = [],
            rolePerList = [],
            projectXmSelect;

        laydate.render({
            elem: '#date-select',
            type: 'year'
        });

        form.render();

        projectXmSelect = xmSelect.render({
            el: '#project-select',
            radio: true,
            clickClose: true,
            filterable: true,
            paging: true,
            pageSize: 5,
            name: 'projectId',
            model: {label: {type: 'text'}},
            data: []
        });

        companyXmSelect = xmSelect.render({
            el: '#company-select',
            radio: true,
            clickClose: true,
            filterable: true,
            paging: true,
            pageSize: 5,
            name: 'companyId',
            model: {label: {type: 'text'}},
            on: function (data) {
                let arr = data.arr;
                if (arr.len !== 0) {
                    let res = []
                    let selectCompanyId = arr[0].value
                    for (let i = 0; i < rolePerList.length; i++) {
                        if (rolePerList[i].companyId == selectCompanyId) {
                            let projectInfos = rolePerList[i].projectInfos
                            for (let j = 0; j < projectInfos.length; j++) {
                                let e = {};
                                e.value = projectInfos[j].projectId;
                                e.name = projectInfos[j].projectName;
                                res[j] = e;
                            }
                        }
                    }
                    projectXmSelect.update(
                        {data: res}
                    )
                }
            }
        })

        febs.get(ctx + 'role/rolePer', null, function (result) {
            console.log(result)
            rolePerList = result.data
            let data = [];
            for (let i = 0; i < rolePerList.length; i++) {
                let e = {};
                e.value = rolePerList[i].companyId;
                e.name = rolePerList[i].companyName;
                data[i] = e;
            }
            companyXmSelect.update(
                {data: data}
            )
        })


        initTreeData()

        function initTreeData() {
            febs.post(ctx + 'business/listTreeData', {type: 5}, function (result) {
                selfTreeData = result.data
            })

            febs.post(ctx + 'business/listTreeData', {type: 4}, function (result) {
                thirdTreeData = result.data
            })
        }

        $query_detail.on('click', function () {
            initTreeData()
            let params = $queryDetailTableForm.serializeJson();
            projectInfo = params;
            params.invalidate_ie_cache = new Date();
            params.yearMonth = params.year + "-" + params.month;
            febs.get(ctx + 'detailCost/queryDetailCost', params, function (result) {
                let data = result.data;
                $companyNameDisplay.text(data.projectInfo.companyName);
                $projectNameDisplay.text(data.projectInfo.projectName);
                $yearMonthDisplay.text(data.projectInfo.yearMonth);
                mainSubjectListData = data.standardMains;
                manualTax = data.projectInfo.manualTax
                //组装元素
                addElement();
                form.render();
                //添加已有的值
                addElementValue(mainSubjectListData);
            })
            return params;
        });

        function addElementValue(mainSubjectListData) {
            for (let i = 0; i < mainSubjectListData.length; i++) {
                let detailCostDTOS = mainSubjectListData[i].detailCostDTOS;
                for (let j = 0; j < detailCostDTOS.length; j++) {
                    let detailSubjectCode = detailCostDTOS[j].detailSubjectCode;
                    let name = detailCostDTOS[j].detailSubjectName
                    let cost = detailCostDTOS[j].cost;
                    let inputTaxAdjustment = detailCostDTOS[j].inputTaxAdjustment;
                    let remark = detailCostDTOS[j].remark;
                    let type = detailCostDTOS[j].type;
                    let estimate = detailCostDTOS[j].estimate == 1 ? 1: null;
                    form.val("detail-" + detailSubjectCode + "-" + type, {
                        cost: cost,
                        remark: remark,
                        estimate: estimate,
                        name: name
                    });
                    if (inputTaxAdjustment != null) {
                        form.val("detail-" + detailSubjectCode + "-" + type, {
                            inputTaxAdjustment: inputTaxAdjustment
                        })
                    }
                }
            }
        }

        function addElement() {
            selfIncomeIndex = 6
            incomeExtraIndex = 7
            let tabs = '';
            let tabTem = '<div class="layui-colla-item"><h2 class="layui-colla-title">{{CHENGBEN}}</h2><div class="layui-colla-content layui-show"><ul>{{DETAILLI}}</ul></div></div>';
            let listr = '<li><div class="layui-form-item layui-form detail-form" lay-filter="{{LAYFILTER}}"  ><div class="layui-inline">{{nameType}}</div><div class="layui-inline"><label class="layui-form-label layui-form-label-sm">{{unit}}</label><div class="layui-input-inline" style="width: 140px"><input type="text" name="cost" autocomplete="off" class="layui-input CLASSDISABLED " style="" DISABLED1 onkeyup="clearNoNum(this)" ></div></div><div class="layui-inline"><label class="layui-form-label layui-form-label-sm">备注</label><div class="layui-input-inline"><textarea rows="2" name="remark"  class="layui-input" ></textarea></div></div><div class="layui-inline"><label class="layui-form-label layui-form-label-sm">预估</label><div class="layui-input-inline" style="width: 100px"><input type="checkbox" name="estimate" lay-skin="switch" lay-text="是|否" value="1"></div></div>{{inputTaxAdjustment}}</div></li>';
            for (let i = 0; i < mainSubjectListData.length; i++) {
                let lis = '';
                let mainSubjectName = mainSubjectListData[i].name;
                for (let j = 0; j < mainSubjectListData[i].detailCostDTOS.length; j++) {
                    let labelType = '<label class="layui-input-inline" style="border: solid 2px rgba(255,255,255,0.2)">{{DETAIL_NAME}}</label>'
                    let inputType = '<textarea rows="2" class="layui-input-inline" name="name" placeholder="{{placeholder}}" style="border: solid 2px #eee"></textarea>'
                    let inputType2 = '<textarea rows="2"  class="layui-input-inline" name="name" disabled="disabled" style="border: solid 2px #eee;background-color: #f6f6f6"></textarea>'
                    let inputTaxAdjustmentStr = '<div class="layui-inline"><label class="layui-form-label layui-form-label-sm">增值税进项税</label><div class="layui-input-inline"><input type="text" name="inputTaxAdjustment" autocomplete="off" class="layui-input CLASSDISABLED " disabled="disabled" style="background-color: #f6f6f6"></div></div>'
                    let detailCostDTO = mainSubjectListData[i].detailCostDTOS[j];
                    let str =  listr.replaceAll("{{LAYFILTER}}", "detail-" + detailCostDTO.detailSubjectCode + "-" + detailCostDTO.type);
                    if (detailCostDTO.inputTaxAdjustment != null) {
                        str = str.replaceAll("{{inputTaxAdjustment}}", inputTaxAdjustmentStr)
                    } else {
                        str = str.replaceAll("{{inputTaxAdjustment}}", "")
                    }
                    if (detailCostDTO.type === 1) {
                        lis += str.replaceAll("{{nameType}}",labelType).replaceAll("DISABLED1", "").replaceAll("CLASSDISABLED", "");
                    } else if (detailCostDTO.type === 4) {
                        inputType = '<div id = "treeNum" class="layui-input-inline"></div>'
                        inputType = inputType.replaceAll("treeNum", "treeNum" + treeNum)
                        thirdIndex.push({index: treeNum, code: detailCostDTO.detailSubjectCode})
                        treeNum++
                        incomeExtraIndex ++
                        lis += str.replaceAll("{{nameType}}",inputType).replaceAll("DISABLED1", "").replaceAll("CLASSDISABLED", "");
                    } else if (detailCostDTO.type === 5) {
                        inputType = '<div id = "treeNum" class="layui-input-inline"></div>'
                        inputType = inputType.replaceAll("treeNum", "treeNum" + treeNum)
                        selfIndex.push({index: treeNum, code: detailCostDTO.detailSubjectCode})
                        treeNum++
                        selfIncomeIndex ++
                        incomeExtraIndex ++
                        lis += str.replaceAll("{{nameType}}",inputType).replaceAll("DISABLED1", "").replaceAll("CLASSDISABLED", "");
                    } else if (detailCostDTO.type === 6) {
                        inputType = inputType2
                        let disableStyle = 'style="background-color: #f6f6f6"'
                        lis += str.replaceAll("{{nameType}}",inputType).replaceAll("DISABLED1", " disabled=\"disabled\"").replaceAll("CLASSDISABLED", "layui-disabled").replaceAll('style=""', disableStyle);
                    } else {
                        if (manualTax === 1 && taxCodes.indexOf(detailCostDTO.detailSubjectCode) !== -1 ) {
                            lis += str.replaceAll("{{nameType}}",labelType).replaceAll("DISABLED1", "").replaceAll("CLASSDISABLED", "");
                        } else {
                            let disableStyle = 'style="background-color: #f6f6f6"'
                            lis += str.replaceAll("{{nameType}}",labelType).replaceAll("DISABLED1", " disabled=\"disabled\"").replaceAll("CLASSDISABLED", "layui-disabled").replaceAll('style=""', disableStyle);
                        }
                    }
                    if ( detailCostDTO.type !== 4 && detailCostDTO.type !== 5) {
                        lis = lis.replaceAll("{{DETAIL_NAME}}", detailCostDTO.detailSubjectName)
                    }
                    lis = lis.replaceAll("{{unit}}", detailCostDTO.unit)
                }
                tabs += tabTem.replaceAll("{{CHENGBEN}}", mainSubjectName).replaceAll("{{DETAILLI}}", lis);
            }
            $projectDetailInfo.html(tabs);
            // 分别添加按钮
            let findStr = 'li:eq(' + (incomeExtraIndex + 1) + ')';
            let addStr = '<div class="layui-inline"><button class="layui-btn">添加</button></div>'
            $projectDetailInfo.find(findStr).find('.layui-form-item.layui-form.detail-form').append(addStr);
            let addBut = $projectDetailInfo.find(findStr).find('.layui-form-item.layui-form.detail-form').find('button');
            addBut.on('click', addExtraIncome);
            findStr = 'li:eq(' + (selfIncomeIndex + 1) + ')';
            $projectDetailInfo.find(findStr).find('.layui-form-item.layui-form.detail-form').append(addStr);
            addBut = $projectDetailInfo.find(findStr).find('.layui-form-item.layui-form.detail-form').find('button');
            addBut.on('click', addSelfIncome);
            addStr = '<div class="layui-inline"><button class="layui-btn" style="background-color: red">删除</button></div>'
            for ( i = selfIncomeIndex  + 2; i <= incomeExtraIndex; i++) {
                findStr = 'li:eq(' + i + ')';
                $projectDetailInfo.find(findStr).find('.layui-form-item.layui-form.detail-form').append(addStr);
                let delBut = $projectDetailInfo.find(findStr).find('.layui-form-item.layui-form.detail-form').find('button');
                delBut.on('click', {ele: delBut}, delExtraIncome);
            }
            for ( i = 7; i <= selfIncomeIndex; i++) {
                findStr = 'li:eq(' + i + ')';
                $projectDetailInfo.find(findStr).find('.layui-form-item.layui-form.detail-form').append(addStr);
                let delBut = $projectDetailInfo.find(findStr).find('.layui-form-item.layui-form.detail-form').find('button');
                delBut.on('click', {ele: delBut}, delSelfIncome);
            }
            initTree()
        }

        function initTree() {
            for (let e of thirdIndex) {
                newTree(2, e.index, [e.code])
            }
            for (let e of selfIndex) {
                newTree(1, e.index, [e.code])
            }
        }

        function addSelfIncome () {
            let listr = '<li><div class="layui-form-item layui-form detail-form" lay-filter="{{LAYFILTER}}"  ><div class="layui-inline">{{nameType}}</div><div class="layui-inline"><label class="layui-form-label layui-form-label-sm">金额</label><div class="layui-input-inline" style="width: 140px"><input type="text" name="cost" autocomplete="off" class="layui-input CLASSDISABLED" DISABLED1 onkeyup="clearNoNum(this)" ></div></div><div class="layui-inline"><label class="layui-form-label layui-form-label-sm">备注</label><div class="layui-input-inline"><textarea rows="2" name="remark"  class="layui-input" ></textarea></div></div><div class="layui-inline"><label class="layui-form-label layui-form-label-sm">预估</label><div class="layui-input-inline" style="width: 100px"><input type="checkbox" name="estimate" lay-skin="switch" lay-text="是|否" value="1"></div></div></div></li>';
            let findStr = 'li:eq(' + selfIncomeIndex + ')';
            let inputType = '<textarea rows="2" class="layui-form-label layui-form-label-md" name="name" placeholder="自有收入" style="border: solid 2px #eee"></textarea>'
            inputType = '<div id = "treeNum" class="layui-input-inline"></div>'
            inputType = inputType.replaceAll("treeNum", "treeNum" + treeNum)
            let code = '[newSelfIncome]' + new Date().getTime().toString();
            let str = listr.replaceAll("{{LAYFILTER}}", "detail-" + code + "-" + '5')
            str = str.replaceAll("{{nameType}}",inputType).replaceAll("DISABLED1", "").replaceAll("CLASSDISABLED", "");
            $projectDetailInfo.find(findStr).after(str);
            newTree(1, treeNum, [])
            treeNum++
            form.val("detail-" + code + "-" + '5', {
                estimate: null
            });
            selfIncomeIndex ++;
            incomeExtraIndex ++;
            findStr = 'li:eq(' + selfIncomeIndex + ')';
            let addStr = '<div class="layui-inline"><button class="layui-btn" style="background-color: red">删除</button></div>'
            $projectDetailInfo.find(findStr).find('.layui-form-item.layui-form.detail-form').append(addStr);
            let delBut = $projectDetailInfo.find(findStr).find('.layui-form-item.layui-form.detail-form').find('button');
            delBut.on('click', {ele: delBut}, delSelfIncome);
        }

        function newTree(val, index, initValue) {
            const treeData = val === 1 ? selfTreeData : thirdTreeData
            xmSelect.render({
                el: '#treeNum' + index,
                radio: true,
                tree: {
                    show: true,
                    strict: false,
                    showLine: true,
                    clickCheck: true,
                    expandedKeys: []
                },
                clickClose: true,
                filterable: true,
                name: 'code',
                prop: {
                    value: 'code'
                },
                model: {label: {type: 'text'}},
                data: treeData,
                initValue: initValue
            });
        }
        
        function addExtraIncome() {
            let listr = '<li><div class="layui-form-item layui-form detail-form" lay-filter="{{LAYFILTER}}"  ><div class="layui-inline">{{nameType}}</div><div class="layui-inline"><label class="layui-form-label layui-form-label-sm">金额</label><div class="layui-input-inline" style="width: 140px"><input type="text" name="cost" autocomplete="off" class="layui-input CLASSDISABLED" DISABLED1 onkeyup="clearNoNum(this)" ></div></div><div class="layui-inline"><label class="layui-form-label layui-form-label-sm">备注</label><div class="layui-input-inline"><textarea rows="2" name="remark"  class="layui-input" ></textarea></div></div><div class="layui-inline"><label class="layui-form-label layui-form-label-sm">预估</label><div class="layui-input-inline" style="width: 100px"><input type="checkbox" name="estimate" lay-skin="switch" lay-text="是|否" value="1"></div></div></div></li>';
            let findStr = 'li:eq(' + incomeExtraIndex + ')';
            let inputType = '<textarea rows="2" class="layui-form-label layui-form-label-md" name="name" placeholder="第三方" style="border: solid 2px #eee"></textarea>'
            inputType = '<div id = "treeNum" class="layui-input-inline"></div>'
            inputType = inputType.replaceAll("treeNum", "treeNum" + treeNum)
            let code = '[ExtraIncome]' + new Date().getTime().toString();
            let str = listr.replaceAll("{{LAYFILTER}}", "detail-" + code + "-" + '4')
            str = str.replaceAll("{{nameType}}",inputType).replaceAll("DISABLED1", "").replaceAll("CLASSDISABLED", "");
            $projectDetailInfo.find(findStr).after(str);
            newTree(2, treeNum, [])
            treeNum++
            form.val("detail-" + code + "-" + '4', {
                estimate: null
            });
            incomeExtraIndex ++;
            findStr = 'li:eq(' + incomeExtraIndex + ')';
            let addStr = '<div class="layui-inline"><button class="layui-btn" style="background-color: red">删除</button></div>'
            $projectDetailInfo.find(findStr).find('.layui-form-item.layui-form.detail-form').append(addStr);
            let delBut = $projectDetailInfo.find(findStr).find('.layui-form-item.layui-form.detail-form').find('button');
            delBut.on('click', {ele: delBut}, delExtraIncome);
        }

        function delSelfIncome(event) {
            event.data.ele.parent().parent().parent().remove()
            selfIncomeIndex --
            incomeExtraIndex --
        }

        function delExtraIncome(event) {
            event.data.ele.parent().parent().parent().remove()
            incomeExtraIndex --
        }

        $submit.on('click', function () {
            let elementsByClassName = document.getElementsByClassName("detail-form");
            let params = [];
            console.log('----')
            console.log(projectInfo)
            for (let i = 0; i < elementsByClassName.length; i++) {
                let layFilter = elementsByClassName[i].getAttribute("lay-filter");
                if (layFilter) {
                    let temp = layFilter.split("-");
                    let data = form.val(layFilter);
                    // console.log("layFilter")
                    // console.log(layFilter)
                    // console.log("data")
                    // console.log(data)
                    let subParams = {};
                    subParams.standardSubCode = temp[1];
                    if (parseInt(temp[2]) === 4 || parseInt(temp[2]) === 5) {
                        subParams.standardSubCode = data.code
                    }
                    subParams.type = temp[2]
                    subParams.cost = data.cost;
                    subParams.remark = data.remark;
                    subParams.estimate = data.estimate;
                    subParams.name = data.name;
                    if (data.inputTaxAdjustment !== undefined) {
                        subParams.inputTaxAdjustment = data.inputTaxAdjustment
                    }
                    params.push(subParams);
                }
            }
            projectInfo.detailCostListStr=JSON.stringify(params);
            projectInfo.invalidate_ie_cache = new Date();
            febs.post(ctx + 'detailCost/save', projectInfo, function () {
                febs.alert.success('修改成功');
                $query_detail.trigger('click');
            })
        });

        $detailComment.on('click', function () {
            if (!projectInfo.hasOwnProperty('projectId') || projectInfo.projectId < 1) {
                febs.alert.error('请先查询项目');
                return;
            }
            febs.modal.open('修改项目批注', 'accounting/project/comment/' + projectInfo.projectId, {
                area: $(window).width() <= 750 ? '90%' : '50%',
                closeBtn: 0,
                maxmin: false,
                btn: ['提交', '取消'],
                yes: function (index, layero) {
                    let commentParams = {id: projectInfo.projectId, comment: document.getElementById('projectComment').value}
                    febs.post(ctx + 'project/updateComment', commentParams, function () {
                        febs.alert.success('修改项目批注成功');
                        layer.closeAll();
                    });
                },
                btn2: function () {
                    layer.closeAll();
                }
            });
        });

        $detailComment2.on('click', function () {
            if (!projectInfo.hasOwnProperty('projectId') || projectInfo.projectId < 1) {
                febs.alert.error('请先查询项目');
                return;
            }
            febs.modal.open('修改项目批注', 'accounting/project/comment2/' + projectInfo.projectId, {
                area: $(window).width() <= 750 ? '90%' : '50%',
                closeBtn: 0,
                maxmin: false,
                btn: ['提交', '取消'],
                yes: function (index, layero) {
                    let commentParams = {id: projectInfo.projectId, comment2: document.getElementById('projectComment2').value}
                    febs.post(ctx + 'project/updateComment2', commentParams, function () {
                        febs.alert.success('修改项目批注成功');
                        layer.closeAll();
                    });
                },
                btn2: function () {
                    layer.closeAll();
                }
            });
        });

    });

    function clearNoNum(obj){
        obj.value = obj.value.replace(/[^\d.-]/g,""); //清除“数字”和“.”以外的字符
        obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的
        obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数
        if(obj.value.indexOf(".")< 0 && obj.value !== "" && obj.value !== "-"){//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
            obj.value= parseFloat(obj.value);
        }
    }

</script>
<style>
    #febs-tools .layui-card-header {
        font-weight: 600;
    }

    #febs-tools p {
        margin-bottom: 10px
    }
</style>